package com.business.business.web.web;

import cn.hutool.json.JSONObject;
import com.business.business.common.base.BaseController;
import com.business.business.support.annotaion.Action;
import com.business.business.support.annotaion.At;
import com.business.business.support.model.RespEntity;
import com.business.business.support.utils.MyLogger;
import com.business.business.web.service.BusinessService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author Yang
 */
@Action
@RequestMapping(value = "business")
public class BusinessController extends BaseController {
    @Resource
    public BusinessService businessService;

    @Resource
    public MyLogger logger;

    /**
     * 消防主管部门树形菜单接口
     *
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/fireDepartmentTreeList", method = RequestMethod.GET)
    public RespEntity fireDepartmentTreeList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.fireDepartmentTreeList(jsonParam);
    }

    /**
     * 行业主管部门树形菜单接口
     *
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/industryAuthoritiesTreeList", method = RequestMethod.GET)
    public RespEntity industryAuthoritiesTreeList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.industryAuthoritiesTreeList(jsonParam);
    }

    /**
     * 行业列表
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/industryList", method = RequestMethod.GET)
    public RespEntity industryList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.industryList(jsonParam);
    }


    /**
     * 单位不分页列表数目
     *
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/businessListCount", method = RequestMethod.GET)
    public RespEntity businessListCount(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessListCount(jsonParam);
    }

    /**
     * 单位新增
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "businessAdd", method = RequestMethod.POST)
    public RespEntity businessAdd(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.businessAdd(jsonObject);
    }

    /**
     * 更新CameraType
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "updateCameraType", method = RequestMethod.POST)
    public RespEntity updateCameraType(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.updateCameraType(jsonObject);
    }

    /**
     * 批量新增单位
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "businessAllAdd", method = RequestMethod.POST)
    public RespEntity businessAllAdd(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.businessAllAdd(jsonObject);
    }
    /**
     * 单位修改
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "businessUpdate", method = RequestMethod.POST)
    public RespEntity businessUpdate(@RequestBody(required = false)JSONObject jsonObject) {
        return this.businessService.businessUpdate(jsonObject);
    }
    /**
     * 行政区划树形菜单接口
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/regionTreeList",method = RequestMethod.GET)
    public RespEntity regionTreeList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionTreeList(jsonParam);
    }
    /**
     * 行政区划列表
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/regionList",method = RequestMethod.GET)
    public RespEntity regionList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionList(jsonParam);
    }

    /**
     * 行政区划新增
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/regionAdd",method = RequestMethod.POST)
    public RespEntity regionAdd(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionAdd(jsonParam);
    }

    /**
     * 行政区划删除
     * @param jsonParam
     * @return
     */
    @At(value = "/regionDel",method = RequestMethod.POST, param = { "id"})
    public RespEntity regionDel(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionDel(jsonParam);
    }
    /**
     * 行政区划编辑
     * @param jsonParam
     * @return
     */
    @At(value = "/regionUpdate",method = RequestMethod.POST, param = { "id"})
    public RespEntity regionUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionUpdate(jsonParam);
    }
    /**
     * 行政区划详情
     * @param jsonParam
     * @return
     */
    @At(value = "/regionDetail",method = RequestMethod.GET, param = { "id"})
    public RespEntity regionDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionDetail(jsonParam);
    }

    /**
     * 行政区划列表
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getGegionList")
    public RespEntity getGegionList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getGegionList(jsonParam);
    }

    /**
     * 查询所有单位的id接口
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getBusinessId",method = RequestMethod.GET)
    public RespEntity getBusinessId(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessId(jsonParam);
    }

    /**
     * 导出单位数据
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getBusiness",method = RequestMethod.GET)
    public RespEntity getBusiness(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusiness(jsonParam);
    }
    /**
     * 查询所有单位
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getBusinessList",method = RequestMethod.GET)
    public RespEntity getBusinessList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 根据行政区划查询单位
     * @Date Created in 15:10 2022/5/24
     * @Param [jsonParam]
     */

    @RequestMapping(value = "/getBusinessLists",method = RequestMethod.GET)
    public RespEntity getBusinessLists(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessLists(jsonParam);
    }

    /**
     * 删除redis里边的key
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/removeKey",method = RequestMethod.POST)
    public RespEntity removeKey(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.removeKey(jsonParam);
    }
    /**
     * 获取单位不分页列表
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/businessList",method = RequestMethod.GET)
    public RespEntity businessList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessList(jsonParam);
    }

    /**
     * 更新区划
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/region",method = RequestMethod.GET)
    public RespEntity region(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.region(jsonParam);
    }


    /**
     * @Author LiHaoDong
     * @Description 单位删除
     * @Date 16:03 2020/7/20
     * @Param [jsonParam]
     * @return com.business.business.support.model.RespEntity
     **/
    @RequestMapping(value = "/businessDelete",method = RequestMethod.POST)
    public RespEntity businessDelete(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessDelete(jsonParam);
    }

    /**
     * @Author LiHaoDong
     * @Description 单位列表
     * @Date 16:05 2020/7/20
     * @Param [jsonParam]
     * @return com.business.business.support.model.RespEntity
     **/
    @At(value = "businessListPage", method = RequestMethod.GET, param = { "page","limit"})
    public RespEntity businessListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessListPage(jsonParam);
    }

    /**
     * 单位详情
     * @param jsonParam
     * @return
     */
    @At(value = "getBusinessDetail", method = RequestMethod.GET)
    public RespEntity getBusinessDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessDetail(jsonParam);
    }

    /**
     * 单位详情(不带token)
     * @param jsonParam
     * @return
     */
    @At(value = "getBusinessDetailNoToken", method = RequestMethod.GET, param = { "id"})
    public RespEntity getBusinessDetailNoToken(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessDetailNoToken(jsonParam);
    }

    /**
     * 字典组查询
     * @param jsonParam
     * @return
     */
    @At(value = "dictList", method = RequestMethod.GET, param = { "groupname"})
    public RespEntity dictList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.dictList(jsonParam);
    }

    @At(value = "shouldknowList", method = RequestMethod.GET)
    public RespEntity shouldknowList(@RequestBody(required = false) JSONObject jsonParam) {
        List list = businessService.shouldknowList("0");
        return RespEntity.success(list);
    }

    //根据消防等级分类统计机构单位数目
    @At(value = "businessCount", method = RequestMethod.GET)
    public RespEntity businessCount(@RequestBody(required = false) JSONObject jsonParam) {
        return this.businessService.businessCount(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 单位接入统计(根据单位类型统计)
     * @Date Created in 11:26 2022/5/24
     * @Param [jsonParam]
     */

    @At(value = "businessCounts", method = RequestMethod.GET)
    public RespEntity businessCounts(@RequestBody(required = false) JSONObject jsonParam) {
        return this.businessService.businessCounts(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 单位类别列表
     * @Date Created in 16:40 2024/4/2
     * @Param [jsonParam]
     */

    @At(value = "businessTypeList", method = RequestMethod.GET)
    public RespEntity businessTypeList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessTypeList(jsonParam);
    }

    /**
     * 获取所有上级行政区划接口
     */
    @At(value = "getAllArea", method = RequestMethod.GET)
    public RespEntity getAllArea(@RequestBody(required = false) JSONObject jsonParam) {
        return this.businessService.getAllArea(jsonParam);
    }

    /**
     * 单位详情统计
     */
    @At(value = "statistics", method = RequestMethod.GET)
    public RespEntity statistics(@RequestBody(required = false) JSONObject jsonParam) {
        return this.businessService.statistics(jsonParam);
    }

    /**
     * 获取监管人员列表
     */
    @At(value = "getCheckmanagePersonList", method = RequestMethod.GET)
    public RespEntity getCheckmanagePersonList(@RequestBody(required = false) JSONObject jsonParam) {
        return this.businessService.getCheckmanagePersonList(jsonParam);
    }

    /**
     * 测试网络
     * @param jsonParam
     * @return
     */
    @At(value = "checkNet", method = RequestMethod.GET)
    public RespEntity checkNet(@RequestBody(required = false) JSONObject jsonParam) {
        businessService.checkNet(jsonParam);
        return RespEntity.success();
    }

    /**
     * 续费
     */
    @At(value = "renew", method = RequestMethod.POST)
    public RespEntity renew(@RequestBody(required = false) JSONObject jsonParam) {
        businessService.renew(jsonParam);
        return RespEntity.success();
    }

    /**
     * @Author YangYu
     * @Description 查看单位服务是否到期
     * @Date Created in 14:10 2022/6/30
     * @Param [jsonParam]
     */

    @At(value = "checkBusinessExpire", method = RequestMethod.GET)
    public RespEntity checkBusinessExpire(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.checkBusinessExpire(jsonParam);
    }

    @At(value = "jsapi/oncallback", method = RequestMethod.POST)
    public Map<String, String> jsapiOnCallback() throws IOException {
        return businessService.onCallback();
    }
    /**
     * 欠费的企业更新账号状态为2
     */
    @At(value = "updateUser", method = RequestMethod.POST)
    public void updateUser() {
         businessService.updateUser();
    }

    /**
     * @Author YangYu
     * @Description 设置仪表盘数据
     * @Date Created in 16:26 2023/2/28
     * @Param [jsonParam]
     */

    @At(value = "setPressureGaugeValue", method = RequestMethod.POST)
    public RespEntity setPressureGaugeValue(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.setPressureGaugeValue(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 获取仪表盘数据
     * @Date Created in 14:10 2022/6/30
     * @Param [jsonParam]
     */

    @At(value = "getPressureGaugeValue", method = RequestMethod.GET)
    public RespEntity getPressureGaugeValue(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getPressureGaugeValue(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 更新企业NFC_ID
     * @Date Created in 16:26 2023/2/28
     * @Param [jsonParam]
     */

    @At(value = "updateBusinessNfcID", method = RequestMethod.POST,param = {"id","nfcId"})
    public RespEntity updateBusinessNfcID(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.updateBusinessNfcID(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description  单位统计(根据单位类别)
     * @Date Created in 17:15 2024/4/27
     * @Param [jsonParam]
     */

    @At(value = "getBusinessTypeCountList", method = RequestMethod.GET)
    public RespEntity getBusinessTypeCountList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessTypeCountList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 施工单位新增、编辑
     * @Date Created in 11:06 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "constructionUnitAddOrUpdate", method = RequestMethod.POST)
    public RespEntity constructionUnitAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.constructionUnitAddOrUpdate(jsonParam);
    }


    /**
     * @Author YangYu
     * @Description 施工单位分页列表
     * @Date Created in 11:17 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "constructionUnitListPage", method = RequestMethod.GET, param = { "page","limit"})
    public RespEntity constructionUnitListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.constructionUnitListPage(jsonParam);
    }


    /**
     * @Author YangYu
     * @Description 施工单位详情
     * @Date Created in 11:17 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "constructionUnitDetails", method = RequestMethod.GET, param = { "id"})
    public RespEntity constructionUnitDetails(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.constructionUnitDetails(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 施工单位资质新增、编辑
     * @Date Created in 11:17 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "aptitudeAddOrUpdate", method = RequestMethod.POST)
    public RespEntity aptitudeAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.aptitudeAddOrUpdate(jsonParam);
    }


    /**
     * @Author YangYu
     * @Description 资质详情
     * @Date Created in 11:17 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "aptitudeDetails", method = RequestMethod.GET, param = { "constructionUnitId","aptitudeType"})
    public RespEntity aptitudeDetails(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.aptitudeDetails(jsonParam);
    }

}
